package com.hnust.dao;

import com.hnust.domain.AlternativeAnswer;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;


/**
 * 备选答案的DAO层
 * @author 42
 * @date 2020/10/29
 */
@Mapper
@Repository
public interface AlternativeAnswerDao {
    @Select("select alt_ans_id,content,`right` from alternative_answer where que_id = #{que_id}")
    @ResultType(AlternativeAnswer.class)
    List<AlternativeAnswer> getQuestionAnswerList(String que_id);
    //获取正确答案
	@Select("select content from alternative_answer where que_id = #{que_id} and `right`= 1 ")
	@ResultType(String.class)
	List<String> getQuestionRightAnswerList(String que_id);

	//删除答案
	@Delete("delete from alternative_answer where que_id = #{id}")
	@ResultType(Integer.class)
	Integer deleteQuestionAnswer(String id);
	//修改题目答案
	@Insert("insert into alternative_answer(alt_ans_id,`right`,content,que_id) values (#{altId},#{right},#{content},#{id})")
	@ResultType(Integer.class)
	Integer addAnswer(String id,String content,Integer right,String altId);
	/*
	 * @Author Tonited
	 * @Author Tonited
	 * @Author Tonited
	 * @Description //TODO 根据题目id返回该题目的备选答案
	 * @Date 15:41 2020/10/31
	 * @Param [questionId]
	 * @return com.hnust.domain.AlternativeAnswer
	 **/
	@Select("select * from alternative_answer where que_id=#{questionId}")
	@ResultType(AlternativeAnswer.class)
	List<AlternativeAnswer> queryAlternativeAnswersByQuestionId(String questionId);
}
